<?php
header('content-type:text/html;charset=utf8');

$dsn = "mysql:host=localhost;dbname=month8;charset=utf8";

$name = $_POST['name'];
$author = $_POST['author'];
$content = $_POST['content'];
$pdo = new PDO($dsn,'root','root');

$sql = "INSERT INTO demo values ('null','$name','$author','$content')";

$res=$pdo->exec($sql);
if($res){
	echo "添加成功";
}else{
	echo '添加失败';
}

$sql = "SELECT * FROM demo";
$sta=$pdo->query($sql);
$res=$sta->fetchAll(PDO::FETCH_ASSOC);
var_dump($res);
?>